package com.msb.config;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.*;

/**
 * @author sunpeng
 * @Date 2021-07-14 11:04
 */

@Configuration(proxyBeanMethods=false)
//@Component
//@Import(value = Person.class) //id="com.msb.config.Person" , type=Person.class 可以放到任意位置
//@EnableConfigurationProperties(value = Person.class) //person-com.msb.config.Person
//@ImportResource("classpath:beans.xml")
@ConditionalOnClass(value = Person.class)
public class MyConfig {

    @Bean
    @ConditionalOnProperty(name = "person.name", havingValue = "sunpeng")
    public Person getPerson(){
        return new Person();
    }
}
